layui.use(['jquery','layer','table','form'],function(){
    var $=layui.jquery;
    var layer=layui.layer;
    var form = layui.form;

    $('#cancel').click(function () {
        var layer = parent.layer;
        layer.close(layer.index)
    });
    $.ajax({
        url: '/product/getProductCategroys',
        dataType: 'json',
        type: 'post',
        success: function (data) {
            var ProductCategroys = data.data;
            for (var i = 0; i < ProductCategroys.length; i++) {
                $('#title').append('<option value="' + ProductCategroys[i].title + '" >' + ProductCategroys[i].title + '</option>')
            }
            form.render('select');
        }
    });
    form.on('submit(sub)',function () {
        var productCode = $("input[name=productCode]").val();
        var currentpriceProduct = $("input[name=currentpriceProduct]").val();
        var title = $("#title option:selected").text();
        var productName = $("input[name=productName]").val();
        $.ajax({
            url:"/product/advancedSearch",
            type:"post",
            dataType:"json",
            data:{'productCode':productCode,'currentpriceProduct':currentpriceProduct,'title':title,'productName':productName,'type':3},
            success:function (data) {
                parent.advancedSearch(data.data);
                var layer = parent.layer;
                layer.close(layer.index);
            }
        })
        return false;
    });
})